<?php
//获取do
$do = $_GET['do'];

switch ($do) {
    case 'getisbn':
        // 由ISBN得到书籍信息
        $isbn = $_POST['isbn'];
        $url='https://api.jike.xyz/situ/book/isbn/'.$isbn.'?apikey=12815.0747cad5bea8984301769a308a20b83a.61398c5fc5858ba457629125433dc6f6'; 
        // $arrContextOptions=array(
        //     "ssl"=>array(
        //     "verify_peer"=>false,
        //     "verify_peer_name"=>false,
        //     ),
        // );
        // $html = file_get_contents($url, false, stream_context_create($arrContextOptions));
        $html = file_get_contents($url);
        echo $html;
        break;
    
    case 'isbn':
        // 图片识别ISBN号
	    //支持php5.5以上版本
	    define("DS",DIRECTORY_SEPARATOR);	//目录分隔符
	    define("ROOT_PATH",getcwd().DS);	//网站根目录
	    include_once ROOT_PATH.'/Frame/Vendor/showapi_sdk/Util/Autoloader.php';//包含sdk中的自动导入工具类
	    $pic = $_POST['imgUrl'];
	    $url = "http://route.showapi.com/1129-3";
	    $METHOD = "POST";
	    $showapi_appid="1040893";//替换此值,你可以在这里找到 https://www.showapi.com/console#/myApp
	    $showapi_sign="66a4a65bd5954cd2bdf88ded17751019";//替换此值,你可以在这里找到 https://www.showapi.com/console#/myApp
	    $req = new ShowapiRequest($url,$showapi_appid,$showapi_sign);
	    $req->addTextPara("imgUrl","$pic");
	    $response=$req->post();
    
        $arr = $response->getContent();
        $arrs = json_decode($arr,true);
		if($arrs['showapi_res_body']['ret_code']==0){
			echo $arrs['showapi_res_body']['retText'];
        	break;
		}else{
			echo 500;
		}
       
        
    default:
        // code...
        break;
}
?>